package com.gxcc3.ygps.common.core.domain;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.gxcc3.ygps.common.core.domain.entity.SysCheckGoodsCategory;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Tree基类
 * 
 * @author ygps
 */
public class TreeEntity
{

    private static final long serialVersionUID = 1L;

    private Long id;

    private String label;

    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<TreeEntity> children;


    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getLabel() {
        return label;
    }

    public void setLabel(String label) {
        this.label = label;
    }

    public List<TreeEntity> getChildren() {
        return children;
    }

    public void setChildren(List<TreeEntity> children) {
        this.children = children;
    }

    public TreeEntity(SysCheckGoodsCategory goodsCategory) {
        this.id = goodsCategory.getId();
        this.label = goodsCategory.getCategoryName();
        this.children = goodsCategory.getChildren().stream().map(TreeEntity::new).collect(Collectors.toList());
    }
}
